package org.example.petsystem.service.impl;


import org.example.petsystem.entity.ResultBody;
import org.example.petsystem.mapper.CollectionMapper;
import org.example.petsystem.service.CollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CollectionServiceimpl implements CollectionService {
    @Autowired
    private CollectionMapper collectionMapper;
    @Override
    public int addCollection(String code,String phone) {
        if(collectionMapper.addCollection(code,phone)>0)
        {
            return 1;
        }
        else
            return 0;
    }
    @Override
    public int DelCollection(String code)
    {
        if(collectionMapper.DelCollection(code)>0)
        {
            return 1;
        }
        else
            return 0;
    }
    public ResultBody displayCollection(String phone)
    {
        if(collectionMapper.displayCollection(phone)!=null)
        {
            return new ResultBody(200,"查询成功",collectionMapper.displayCollection(phone),collectionMapper.displayCollection(phone).size());
        }
        else
            return new ResultBody(400,"查询失败",false);
    }

}
